home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-09-11 | 58.2 KB | 2,476 lines |
-
-
- #define _ENTRY_
-
- #ifdef __TURBOC__
- #include <conio.h>
- #else
- #include <graph.h>
- #endif
- #include <io.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "db_lsc.h"
- #include "db_types.h"
- #include "db_conio.h"
- #include "db_curs.h"
- #include "db_date.h"
- #include "db_dos.h"
- #include "db_file.h"
- #include "extfhc.h"
- #include "db_funcs.h"
- #include "db_heap.h"
- #include "db_gvar.h"
- #include "db_key.h"
- #include "db_pswd.h"
- #include "db_sets.h"
- #include "db_str.h"
- #include "db_win.h"
- #include "db_mnu.h"
- #include "db_util.h"
- #include "db_work.h"
- #include "db_tree.h"
- #include "db_list.h"
- ¸USES¸
- ¸IFDEF MANUAL¸
- #include "db_man.h"
- ¸ENDDEF¸
- ¸IFDEF MEMOS¸
- #include "db_memo.h"
- ¸ENDDEF¸
-
- unsigned _stklen = 0x4000; /* Default stack of 16 K */
-
- string _tts, _tranString; /* _tranString for internal generator use only */
-
- /********************************* TYPES **********************************/
-
- typedef struct {
- char exeid[9];
- byte anchor;
- int deltat;
- } defaultrec;
-
- typedef enum {Cmd_No_Command,
- Cmd_Next_Record,
- Cmd_Prev_Record,
- Cmd_Find_Record,
- Cmd_Top_Record,
- Cmd_Last_Record,
- Cmd_Edit_Record,
- Cmd_Add_Record,
- Cmd_Copy_Record,
- Cmd_Delete_Record,
- Cmd_Next_File,
- Cmd_Prev_File,
- Cmd_Swap_Menu
- }commandtyp;
-
- ¸IFDEF LINKED¸
- typedef struct {
- byte f;
- byte k;
- byte l;
- uchar t;
- } lback;
- ¸ENDDEF¸
-
- typedef struct savmtyp {
- pathstr savnam;
- byte savno;
- char savprompt[81];
- pathstr savpath;
- struct savmtyp *savprv;
- } savmtyp, *savmptr;
-
- /************************* INITIALIZED VARIABLES **************************/
-
- defaultrec def1 = {"îDBPSKL_",0,150};
-
- namestr applname = "¸MODNAME¸";
- pathstr localmenu = "¸MENUNAME¸";
-
- #define maxfilno ¸maxfilno¸
- #define maxkeyno ¸maxkeyno¸
-
- str12 dbnames[maxfilno+1][maxkeyno+1] = /* [1.. ,0.. ] */
- ¸dbnames¸;
- long maxrec[maxfilno+1] =
- ¸maxrec¸;
- byte keymode[maxfilno+1][maxkeyno+1] = /* [1.. ,1.. ] */
- ¸keymode¸;
- byte keylen[maxfilno+1][maxkeyno+1] = /* [1.. ,1.. ] */
- ¸keylen¸;
- byte keyseg1len[maxfilno+1][maxkeyno+1] =
- ¸keyseg1len¸;
- char keyuse[maxfilno+1][maxkeyno+1] = /* [1.. ,1.. ] */
- ¸keyuse¸;
- char keytype[maxfilno+1][maxkeyno+1] = /* [1.. ,1.. ] */
- ¸keytype¸;
- byte keyfld[maxfilno+1][maxkeyno+1] = /* [1.. ,1.. ] */
- ¸KeyFld¸;
- findwtyp findscrpos[maxfilno+1][maxkeyno+1] = /* [1.. ,1.. ] */
- ¸findscrpos¸;
- bool filinuse[maxfilno+1] =
- ¸filinuse¸;
- byte winforfile[maxfilno+1] =
- ¸winforfile¸;
-
- ¸IFDEF ADJUST¸
- int afteradj[maxfilno+1][maxfilno+1] =
- ¸afteradj¸;
- ¸ENDDEF¸
-
- ¸IFDEF TABLES¸
- byte tabsize[maxfilno+1] =
- ¸TableSizes¸;
- ¸ENDDEF¸
-
- ¸IFDEF LINKED¸
- lback linkback[maxfilno+1] =
- ¸newlinkback¸;
- ¸ENDDEF¸
-
- str20 keynamtab[maxfilno+1][maxkeyno+1] =
- ¸keynamtab¸;
-
- bool menudriven = ¸menudriven¸;
-
- /******************************* VARIABLES ********************************/
-
- ¸IFDEF TABLES¸
- bool switchtab,leaveclear;
- recnotyp tabrecno;
- byte tabidx[maxfilno+1];
- byte tabused[maxfilno+1];
- ¸ENDDEF¸
-
- bool pathSwap;
- savmptr smc, svm;
- string tempString;
- byte menuanchor;
- bool quit,fok,cleartop,scrn_active, listAndAdd;
- int keynum,_trace,filno,scrno,dispsno;
- long nextrec;
- keystr key,skey,tempkey;
- mnufrec dm;
- winfrec uw,hw;
- winptr twinp;
- int dbsize[maxfilno+1];
- datafile *datf[maxfilno+1];
- indexfile *idxkey[maxfilno+1][maxkeyno+1];
- keystr tkeytab[maxkeyno+1], savkey[maxkeyno+1];
- fldtyp *keyseg1fld[maxfilno + 1][maxkeyno + 1];
-
- ¸IFDEF LINKED¸
- string savelnk[maxfilno+1];
- ¸ENDDEF¸
-
- ¸IFDEF MUSER¸
- bool lockByDel[maxfilno+1];
- ¸ENDDEF¸
-
- int tv;
- char lastrecop;
- commandtyp command;
-
- ¸RECMOD¸
-
- bool custom_key(int scr, int fno, int *fld, uchar *key);
- void getarec(int fno);
- void putarec(int fno);
- void displayrec(int fno, int sno);
- void clear_rec(int fno);
- strptr list(strptr sout, int fno, int kno, keystr ks);
- strptr listadd(strptr sout, int fno, int kno, keystr aKey);
-
- void tandk(int x, int y, winptr w)
- {
- string ts;
-
- while (!kpressed()) {
- if (mtime.x) writewxy(get_time(ts,(_timemode)(mtime.m)),0,mtime.x,mtime.y,NULL);
- if (mksta.x) writewxy(keystat(ts,0),0,mksta.x,mksta.y,NULL);
- }
- }
-
- bool found(int fno, int kno, keystr chkkey)
- {
- bool tok;
- bool tfound;
- keystr aKey; /* SN 3.5 */
-
- tok = ok;
- if ((fno != filno) && (keylen[fno][kno] > 0)) {
- strcpy(aKey,chkkey); /* SN 3.5 */
- searchkey(idxkey[fno][kno], &recno[fno], aKey); /* SN 3.5 */
- ok = (bool)(ok && (strsearch(aKey, chkkey) == aKey)); /* SN 3.5 */
- if (ok) switch (fno) {
- ¸getrec¸
- }
- tfound = ok;
- }
- else tfound = False;
-
- ok = tok;
- recavail[fno] = tfound;
- return(tfound);
- }
-
- ¸FUNCMOD¸
- ¸SCRNMOD¸
-
- void openfiles(void)
- {
- int i, j, fo_i, fo_j;
- string prepend;
- int tlen;
- string ts;
-
- fo_i = fo_j = 0;
-
- ¸SIZES¸;
-
- strip(prepend,datapath);
- tlen = strlen(prepend);
- if ((tlen > 0) && (prepend[tlen-1] != '\\')) {
- prepend[tlen] = '\\';
- prepend[tlen+1] = '\0';
- }
-
- fok = True;
- for (i=1;i <= maxfilno; i++)
- if (fok) {
- datf[i] = db_malloc(sizeof(datafile));
- strconcat(ts,prepend,dbnames[i][0],NULL);
- openfile(datf[i],ts,dbsize[i]);
- fok = (bool)(fok && ok);
- if (fok) {
- fo_i = i;
- fo_j = 0;
- for (j=1; j <= maxkeyno; j++)
- if (fok && (keylen[i][j] > 0)) {
- idxkey[i][j] = db_malloc(sizeof(indexfile));
- strconcat(ts,prepend,dbnames[i][j],NULL);
- openindex(idxkey[i][j],ts,keylen[i][j],keymode[i][j]);
- fok = (bool)(fok && ok);
- if (fok) fo_j = j;
- }
- }
- else if (filinuse[i]) {
- strconcat(ts,prepend,dbnames[i][0],NULL);
- makefile(datf[i],ts,dbsize[i]);
- fok = ok;
- if (fok) {
-
- ¸IFDEF MUSER¸
- closefile(datf[i]);
- strconcat(ts,prepend,dbnames[i][0],NULL);
- openfile(datf[i],ts,dbsize[i]);
- ¸ENDDEF¸
-
- fo_i = i; fo_j = 0;
- for (j=1; j <= maxkeyno; j++)
- if (fok && (keylen[i][j] > 0)) {
- idxkey[i][j] = db_malloc(sizeof(indexfile));
- strconcat(ts,prepend,dbnames[i][j],NULL);
- makeindex(idxkey[i][j],ts,keylen[i][j],keymode[i][j]);
- fok = (bool)(fok && ok);
- if (fok) {
-
- ¸IFDEF MUSER¸
- closeindex(idxkey[i][j]);
- strconcat(ts,prepend,dbnames[i][j],NULL);
- openindex(idxkey[i][j],ts,keylen[i][j],keymode[i][j]);
- fo_j = j;
- ¸ELSEDEF¸
- fo_j = j;
- ¸ENDDEF¸
-
- }
- }
- }
- }
- }
- if (!fok)
- for (i=1; i <= maxfilno; i++)
- if (i <= fo_i) {
- closefile(datf[i]);
- db_free(datf[i]);
- for (j=1; j <= maxkeyno; j++)
- if ((i < fo_i) || (j <= fo_j))
- if (keylen[i][j] > 0) {
- closeindex(idxkey[i][j]);
- db_free(idxkey[i][j]);
- }
- }
- }
-
- void closefiles(void)
- {
- int i,j;
-
- for (i=1; i <= maxfilno; i++) {
- closefile(datf[i]); db_free(datf[i]);
- for (j=1; j <= maxkeyno; j++) if (keylen[i][j] > 0) {
- closeindex(idxkey[i][j]);
- db_free(idxkey[i][j]);
- }
- }
- }
-
- ¸IFDEF MUSER¸
- void must_secure_rec(int fno, long rno, int m)
- {
- if (multiuser)
- do {
- tv = lock_datf(datf[fno],rno,Lock);
- if (tv == -1)
- switch (m) {
- case 1 : dspmsge(LSC_Warning,LSC_LinkedRecInUse,4.0);break;
- case 2 : dspmsge(LSC_Warning,LSC_StatusRecLocked,4.0);break;
- }
- } while (tv);
- }
-
- bool chkabortretry(strptr instr)
- {
- return((bool)((*instr == _Abort) || (*instr == _Retry)));
- }
-
- void must_secure_index(int fno, int kno, byte lck)
- {
- int tmp,count;
- uchar again[2],retry[2],tpic[2];
-
- count = 0;
- if (multiuser)
- do {
- count++;
- if (count >= 1000) {
- dbgetstr(again,_Ch,LSC_Complications,chstr(retry,_Retry),chstr(tpic,Pic_U),"",chkabortretry,nohelp);
- if (*again == _Retry) count = 0;
- else {
- closefiles();
- exit(0);
- }
- }
- tmp = lock_indexf(idxkey[fno][kno],-1L,lck);
- } while (tmp);
- }
- ¸ENDDEF¸
-
- strptr makekey(strptr sout, int fno, int kno)
- {
- string ks, ts;
- string tempString;
-
- ks[0] = '\0';
-
- ¸makekey¸
-
- strcpy(sout,ks);
- return(sout);
- }
-
- strptr keyexpr(strptr sout, int fno, int kno, string kvar)
- {
- string ts, ks;
- byte tlen;
-
- strcpy(ks,kvar);
- tlen = strlen(ks);
-
- ¸keyexpr¸
-
- ks[tlen] = Nul;
- strcpy(sout,ks);
- return(sout);
- }
-
- strptr getakey(strptr sout, int fno, int kno)
- {
- keyexpr(sout,fno,kno,makekey(sout,fno,kno));
- return(sout);
- }
-
- ¸IFDEF LINKED¸
- strptr getlink(strptr sout, int fno)
- {
- string tkey;
-
- tkey[0] = '\0';
-
- ¸GetKLink¸
-
- strcopy(sout,tkey,0,linkback[fno].l);
- return(sout);
- }
- ¸ENDDEF¸
-
- void edit_rec(int fld)
- {
- edthook = tandk;
-
- ¸IFDEF TABLES¸
- ¸MODNAME¸_edt(filno,fld,tabidx[filno] - 1);
- ¸ELSEDEF¸
- ¸MODNAME¸_edt(filno,fld,0);
- ¸ENDDEF¸
-
- edthook = NULL;
- }
-
- bool status_ok(int fno)
- {
- bool tok;
- keystr tk1, tk2;
-
- tok = (bool)(usedrecs(datf[fno]) > 0);
-
- ¸IFDEF LINKED¸
- if (linkback[fno].f > 0) {
- getlink(tk1,fno);
- strcopy(tk2,getakey(tk2,fno,1),0,linkback[fno].l);
- tok = (bool)(tok && recavail[linkback[fno].f] && (strcmp(tk1,tk2) == 0));
- }
- ¸ENDDEF¸
-
- recavail[fno] = tok;
- return(tok);
- }
-
- void clearbuf(ptr fb)
- {
- word w;
- string tpic;
- fldblk *fblk;
- fldtyp *ftp;
-
- fblk = fb;
- for (w=0; w < fblk->numf; w++) {
- ftp = &(*fblk->farr)[w];
- expand(tpic,ftp->pic);
- switch (ftp->typ) {
- case _Ch : fillstr(ftp->faddr,piclen(tpic,ftp->typ),' '); break;
- case _Num : fstr(ftp->faddr,0.0,_calc_int(tpic),_calc_frac(tpic)); break;
-
- ¸IFDEF MEMOS¸
- case _Memo : memset(ftp->faddr,0,4); break;
- ¸ENDDEF¸
-
- }
- }
- }
-
- ¸IFDEF MEMOS¸
- void clearmemo(ptr fb)
- {
- word w;
- fldblk *fblk;
- bool memofile;
- fldtyp *ftp;
-
- fblk = fb;
- memofile = False;
- for (w=0; w < fblk->numf; w++) {
- ftp = &(*fblk->farr)[w];
- if (ftp->typ == _Memo) {
- memofile = True;
- memset(ftp->faddr,0,4);
- }
- }
- if (memofile) displayrec(filno,scrno);
- }
- ¸ENDDEF¸
-
- void clear_rec(int fno)
- {
-
- ¸IFDEF LINKED¸
- int i;
-
- if (link == Up_N_Down)
- for (i=1; i <= maxfilno; i++)
- if (linkback[i].f == (byte)fno) clear_rec(i);
- ¸ELSEDEF¸
- ¸ENDDEF¸
-
- if (cleartop || (fno != filno)) {
- switch (fno) {
- ¸CLEARBUF¸
- }
- displayrec(fno,scrno);
- }
- }
-
- /* SN 3.5 - the whole function was created for this version 3.5 */
-
- long add2CodeFile(int fileNumber)
- {
- bool saveOk,
- aOk;
- byte keyNumber, keyNumberCount;
- keystr aKey;
- char *aBufferPtr,
- *aFieldPtr,
- errorMessage[256];
-
-
-
- saveOk = ok;
- *(recno + fileNumber) = 0;
-
- switch(fileNumber) {
-
- ¸CODEFILEBUF¸
-
- default :
- aBufferPtr = aFieldPtr = 0;
- break;
- }
-
- if (aBufferPtr) {
- clearbuf(aFieldPtr);
- memmove(aBufferPtr, &recno[fileNumber], 4);
- do {
- ok = False;
- editdefaultdata(fileNumber, aFieldPtr);
- if (exitcode != QitKey) {
- ¸IFDEF MUSER¸
- must_secure_rec(fileNumber, 0, 2);
- ¸ENDDEF¸
- addrec(datf[fileNumber], &recno[fileNumber], aBufferPtr);
- ¸IFDEF MUSER¸
- tv = lock_datf(datf[fileNumber], recno[fileNumber], Lock);
- tv = lock_datf(datf[fileNumber], 0, UnLock);
- ¸ENDDEF¸
- keyNumber = 0;
- ok = True;
- while (ok && (keyNumber < maxkeyno)) {
- keyNumber++;
- if (keylen[fileNumber][keyNumber]) {
- getakey(aKey, fileNumber, keyNumber);
- ¸IFDEF MUSER¸
- must_secure_index(fileNumber, keyNumber, Lock);
- addkey(idxkey[fileNumber][keyNumber], &recno[fileNumber], aKey);
- must_secure_index(fileNumber, keyNumber, UnLock);
- ¸ELSEDEF¸
- addkey(idxkey[fileNumber][keyNumber], &recno[fileNumber], aKey);
- ¸ENDDEF¸
- }
- }
- if (!ok) {
- audible(Error);
- dspmsge(LSC_BaseError, strconcat(errorMessage, LSC_KeyExists, "(", keynamtab[fileNumber][keyNumber], ")"), 4);
- for (keyNumberCount = 1; keyNumberCount < keyNumber; keyNumberCount++) {
- if (keylen[fileNumber][keyNumberCount]) {
- getakey(aKey, fileNumber, keyNumberCount);
- ¸IFDEF MUSER¸
- must_secure_index(fileNumber, keyNumberCount, Lock);
- deletekey(idxkey[fileNumber][keyNumberCount], &recno[fileNumber], aKey);
- must_secure_index(fileNumber, keyNumberCount, UnLock);
- ¸ELSEDEF¸
- deletekey(idxkey[fileNumber][keyNumberCount], &recno[fileNumber], aKey);
- ¸ENDDEF¸
- }
- }
-
- ¸IFDEF MUSER¸
- must_secure_rec(fileNumber, 0, 2);
- deleterec(datf[fileNumber], recno[fileNumber]);
- tv = lock_datf(datf[fileNumber], 0, UnLock);
- ¸ELSEDEF¸
- deleterec(datf[fileNumber], recno[fileNumber]);
- ¸ENDDEF¸
-
- ok = False;
- }
-
- ¸IFDEF MUSER¸
- tv = lock_datf(datf[fileNumber], recno[fileNumber], UnLock);
- ¸ENDDEF¸
- }
- }while (!ok && (exitcode != QitKey));
-
- if (exitcode == QitKey) {
- clearbuf(aFieldPtr);
- recno[fileNumber] = 0;
- }
- }
-
- ok = saveOk;
- exitcode = Nul;
- return(recno[fileNumber]);
- }
-
- bool skip(char dirn, int fno)
- {
- bool fval;
- string ts;
-
- fval = True;
- if (dirn == _Next) nextkey(idxkey[fno][1],&recno[fno],key);
- else prevkey(idxkey[fno][1],&recno[fno],key);
-
- ¸IFDEF LINKED¸
- if (linkback[fno].f > 0) ok = (bool)(ok && (strsearch(key,getlink(ts,fno)) == key));
- ¸ENDDEF¸
-
- if (!ok) {
- fval = False;
- if (dirn == _Next) prevkey(idxkey[fno][1],&recno[fno],key);
- else nextkey(idxkey[fno][1],&recno[fno],key);
- }
- return(fval);
- }
-
- void getarec(int fno)
- {
- int i;
- string tkey;
- string ts;
-
- ¸IFDEF LINKED¸
- ¸IFDEF TABLES¸
- bool tb;
- ¸ENDDEF¸
- ¸ENDDEF¸
-
- tkey[0] = '\0';
- recavail[fno] = ok;
- if (ok)
- switch (fno) {
- ¸GETREC¸
- }
- ¸IFDEF LINKED¸
- if ((!recavail[fno]) ||
- ((link != No_Link) && (_trace != fno) && !status_ok(fno))) {
- ¸IFDEF TABLES¸
- tb = scrn_active;
- scrn_active = False;
- clear_rec(fno);
- scrn_active = tb;
- ¸ELSEDEF¸
- clear_rec(fno);
- ¸ENDDEF¸
- recavail[fno] = False;
- }
- if (link != No_Link) {
- ¸IFDEF TABLES¸
- if ((tabsize[fno] > 1) && (fno != filno) && !switchtab) {
- tabrecno[fno] = recno[fno]; tabidx[fno] = 1;
- }
- ¸ENDDEF¸
- for (i=1; i <= maxfilno; i++)
- if (linkback[i].f == (byte)fno)
- if (!status_ok(i)) {
- getlink(tkey,i);
- searchkey(idxkey[i][1],&recno[i],tkey);
- ok = (bool)(ok && (strsearch(tkey,getlink(ts,i)) == tkey));
- getarec(i); /* recursion */
- }
- }
- ¸ELSEDEF¸
- if (!recavail[fno] || !status_ok(fno)) {
- clear_rec(fno);
- recavail[fno] = False;
- }
- ¸ENDDEF¸
- if (fno == filno) ok = recavail[fno];
- }
-
- void putarec(int fno)
- {
- if (recavail[fno]) {
- switch (fno) {
- ¸PUTREC¸
- }
- }
- }
-
- void top_record(void)
- {
- ¸IFDEF LINKED¸
- if (!linkback[filno].f) {
- clearkey(idxkey[filno][1]);
- nextkey(idxkey[filno][1],&recno[filno],key);
- }
- else {
- getlink(tempkey,filno);
- strcpy(skey,tempkey);
- searchkey(idxkey[filno][1],&recno[filno],tempkey);
- ok = (bool)(ok && (strsearch(tempkey,skey) == tempkey));
- }
- ¸ELSEDEF¸
- clearkey(idxkey[filno][1]);
- nextkey(idxkey[filno][1],&recno[filno],key);
- ¸ENDDEF¸
- if (ok)
- getarec(filno);
- else {
- clear_rec(filno);
- recavail[filno] = False;
- }
- ¸IFDEF TABLES¸
- if (tabsize[filno] > 1) {
- tabrecno[filno] = recno[filno]; tabidx[filno] = 1;
- }
- ¸ENDDEF¸
- displayrec(filno,scrno);
- }
-
- void findmulti(int fno, long *recn, strptr key2find)
- {
- long saverecn;
- keystr savk2f;
-
- saverecn = *recn;
- strcpy(savk2f,key2find);
- searchkey(idxkey[fno][1],recn,key2find);
- ok = (bool)(ok && (strsearch(key2find,savk2f) == key2find));
- while ((*recn != saverecn) && ok) {
- nextkey(idxkey[fno][1],recn,key2find);
- ok = (bool)(ok && (strsearch(key2find,savk2f) == key2find));
- }
- }
-
- ¸IFDEF TABLES¸
- void gettabrec(byte fno)
- {
- switch (fno) {
- ¸GetTabRec¸
- }
- }
-
- void disptab(byte fno)
- {
- byte incy;
- long srec;
- bool rec_ok;
- string tk;
-
- if (tabsize[fno] < 2) {
- incy = tabidx[fno]-1;
- ¸MODNAME¸_dsp(fno,dispsno,incy);
- }
- else {
- incy = 0;
- rec_ok = recavail[fno];
- if (rec_ok) {
- srec = recno[fno];
- ¸IFDEF LINKED¸
- if (!leaveclear || (linkback[fno].f != (byte)filno)) gettabrec(fno);
- ¸ELSEDEF¸
- if (!leaveclear) gettabrec(fno);
- ¸ENDDEF¸
- getakey(tk,fno,1);
- findmulti(fno,&tabrecno[fno],tk);
- if (!ok) {
- scrn_active = False;
- clear_rec(fno);
- scrn_active = True;
- rec_ok = False;
- }
- if ((tabidx[fno] > tabsize[fno]) && (skip(_Next,fno))) {
- tabidx[fno] = tabsize[fno];
- tabrecno[fno] = recno[fno];
- gettabrec(fno);
- }
- if ((tabidx[fno] == 0) && (skip(_Prev,fno))) {
- tabidx[fno] = 1;
- tabrecno[fno] = recno[fno];
- gettabrec(fno);
- }
- }
- (uw.wa[dispsno])->disp = False;
- tabused[fno] = 0;
- do {
- ¸MODNAME¸_dsp(fno,dispsno,incy);
- incy++;
- if (rec_ok && (incy < tabsize[fno])) {
- tabused[fno] = incy;
- link = No_Link;
- ¸IFDEF LINKED¸
- if ((!leaveclear || (linkback[fno].f != (byte)filno)) && recavail[fno]) {
- ¸ELSEDEF¸
- if (!leaveclear && recavail[fno]) {
- ¸ENDDEF¸
- if (skip(_Next,fno)) getarec(fno);
- else {
- scrn_active = False;
- clear_rec(fno);
- scrn_active = True;
- rec_ok = False;
- }
- }
- else {
- scrn_active = False;
- clear_rec(fno);
- scrn_active = True;
- rec_ok = False;
- }
- link = Up_N_Down;
- }
- } while (incy < tabsize[fno]);
- (uw.wa[dispsno])->disp = True; dispwindow(uw.wa[dispsno]);
- if (recavail[fno]) {
- recno[fno] = srec;
- ¸IFDEF LINKED¸
- if (!leaveclear || (linkback[fno].f != (byte)filno)) getarec(fno);
- ¸ELSEDEF¸
- if (!leaveclear) getarec(fno);
- ¸ENDDEF¸
- else {
- link = No_Link;
- getarec(fno);
- link = Up_N_Down;
- }
- getakey(tk,fno,1);
- findmulti(fno,&srec,tk);
- }
- }
- }
- ¸ENDDEF¸
-
- void dispfields(int fno, int sno)
- {
- ¸IFDEF TABLES¸
- dispsno = sno;
- ¸ENDDEF¸
- switch (sno) {
- ¸DispFields¸
- }
- }
-
- void displayrec(int fno, int sno)
- {
- if (scrn_active) dispfields(fno,sno);
- }
-
- void switch_file(char mode)
- {
- int fno,incr;
-
- scrn_active = True;
- if (mode == '+') incr = 1;
- else if (mode == '-') incr = -1;
- else incr = 0;
- fno = filno;
- do {
- filno += incr;
- if ((filno < 1) || (filno > maxfilno)) {
- incr = -incr; filno += incr;
- audible(Warning);
- }
- } while (!filinuse[filno] && (filno != fno));
-
- if (scrno < winforfile[filno]) displayrec(filno,scrno);
- while (scrno > winforfile[filno]) {
- hidewin(T_OFF,uw.wa[scrno]);
- scrno--;
- }
-
- while (scrno < winforfile[filno]) {
- scrno++;
- hidewin(T_ON,uw.wa[scrno]);
- }
-
- if (!status_ok(filno)) top_record(); else ok = True;
- ¸IFDEF TABLES¸
- switchtab = True;
- displayrec(filno,scrno);
- switchtab = False;
- ¸ELSEDEF¸
- displayrec(filno,scrno);
- ¸ENDDEF¸
- }
-
- ¸IFDEF LINKED¸
- void traceback(int fno)
- {
- string tk,sk;
- int f,k;
-
- f = linkback[fno].f;
- k = linkback[fno].k;
- _trace = f;
- if (recavail[fno]) {
- strcopy(tk,getakey(tk,fno,1),0,linkback[fno].l); strcpy(sk,tk);
- searchkey(idxkey[f][k],&recno[f],tk);
- ok = (bool)(ok && (strsearch(tk,sk) == tk));
- if (ok) {
- getarec(f);
- ok = status_ok(fno);
- ¸IFDEF TABLES¸
- if (tabsize[f] > 1) {
- tabrecno[f] = recno[f]; tabidx[f] = 1;
- }
- ¸ENDDEF¸
- if (ok && (k > 1)) {
- getakey(tk,f,1);
- findmulti(f,&recno[f],tk);
- }
- }
- }
- else ok = True;
-
- if (!ok) {
- audible(Error);
- dspmsge(LSC_BaseError,LSC_TracebackFailed,4.0);
- filno = 1;
- switch_file(' ');
- top_record();
- }
- else
- if (linkback[f].f > 0)
- traceback(f);
- _trace = 0;
- ok = status_ok(fno);
- }
- ¸ENDDEF¸
-
- ¸IFDEF TABLES¸
- void align_tab(int fno)
- {
- byte count;
- long srno;
- string ts;
-
- getakey(tempkey,fno,1);
- strcpy(skey,tempkey);
- srno = recno[fno];
- count = 1;
- do {
- prevkey(idxkey[fno][1],&recno[fno],tempkey);
- ¸IFDEF LINKED¸
- ok = (bool)(ok && (strsearch(tempkey,getlink(ts,fno)) == tempkey));
- ¸ENDDEF¸
- if (ok) count++;
- } while ((count <= tabsize[fno]) && ok);
-
- if (!ok) nextkey(idxkey[fno][1],&recno[fno],tempkey);
- tabidx[fno] = count;
- tabrecno[fno] = recno[fno];
- recno[fno] = srno;
- findmulti(filno,&recno[fno],skey);
- }
- ¸ENDDEF¸
-
- void displayall(void)
- {
- int i;
-
- for (i=1; i <= filno; i++) (uw.wa[winforfile[i]])->disp = False;
- ¸IFDEF TABLES¸
- link = No_Link;
- for (i=1; i <= scrno; i++) displayrec(0,i);
- link = Up_N_Down;
- ¸ELSEDEF¸
- for (i=1; i <= scrno; i++) displayrec(filno,i);
- ¸ENDDEF¸
- for (i=1; i <= filno; i++) hidewin(T_ON,uw.wa[winforfile[i]]);
- }
-
- void align_rec(long oldr)
- {
- int i;
-
- ok = True;
- _trace = filno;
- recno[filno] = oldr;
- scrn_active = False;
- if (oldr > 0) getarec(filno);
- else recavail[filno] = False;
-
- if (recavail[filno]) {
- getakey(skey,filno,1);
- findmulti(filno,&oldr,skey);
- if (!ok) {
- audible(Error);
- dspmsge(LSC_BaseError,LSC_Mismatch,4.0);
- ¸IFDEF MUSER¸
- filno = 1; scrno = 1;
- ¸ENDDEF¸
- top_record();
- }
- }
- else top_record();
- ¸IFDEF LINKED¸
- if (linkback[filno].f > 0) traceback(filno);
- ¸ENDDEF¸
- ¸IFDEF TABLES¸
- if (tabsize[filno] > 1) align_tab(filno);
- ¸ENDDEF¸
- _trace = 0;
- scrn_active = True;
- displayall();
- }
-
- void next_record(char dirn)
- {
- long savr;
-
- if (status_ok(filno)) {
- savr = recno[filno];
- if (skip(dirn,filno)) {
- getarec(filno);
- ¸IFDEF TABLES¸
- if (tabsize[filno] > 1)
- if (dirn == _Next) tabidx[filno]++; else tabidx[filno]--;
- ¸ENDDEF¸
- if (!recavail[filno]) align_rec(savr);
- else displayrec(filno,scrno);
- }
- else audible(Warning);
- if (!ok) top_record();
- }
- else audible(Warning);
- }
-
- ¸IFDEF TABLES¸
- void next_tab_page(char dirn)
- {
- byte count;
-
- if ((tabsize[filno] > 1) && status_ok(filno)) {
- count = 1;
- while ((count < tabsize[filno]) && skip(dirn,filno)) count++;
- getarec(filno);
- align_tab(filno);
- displayrec(filno,scrno);
- }
- }
- ¸ENDDEF¸
-
- void last_record(void)
- {
- long savr;
-
- if (status_ok(filno)) {
- savr = recno[filno];
- ¸IFDEF LINKED¸
- if (linkback[filno].f == 0) {
- clearkey(idxkey[filno][1]);
- prevkey(idxkey[filno][1],&recno[filno],key);
- }
- else {
- getlink(tempkey,filno);
- strcpy(skey,tempkey);
- searchkey(idxkey[filno][1],&recno[filno],tempkey);
- ok = (bool)(ok && (strsearch(tempkey,skey) == tempkey));
- if (ok) {
- while (ok) {
- nextkey(idxkey[filno][1],&recno[filno],tempkey);
- ok = (bool)(ok && (strsearch(tempkey,skey) == tempkey));
- }
- prevkey(idxkey[filno][1],&recno[filno],tempkey);
- }
- }
- ¸ELSEDEF¸
- clearkey(idxkey[filno][1]);
- prevkey(idxkey[filno][1],&recno[filno],key);
- ¸ENDDEF¸
- if (!ok) top_record();
- else {
- getarec(filno);
- ¸IFDEF TABLES¸
- if (tabsize[filno] > 1) align_tab(filno);
- ¸ENDDEF¸
- if (!recavail[filno]) align_rec(savr);
- else displayrec(filno,scrno);
- }
- }
- else audible(Warning);
- }
-
- strptr horizrec(strptr sout, uchar mode, byte fno, byte kno)
- {
- string ts;
-
- strcpy(ts, "~");
- if (mode == _Header) {
- switch (fno) {
- ¸SELHEADER¸
- }
- if (ts[0] == '~') strconcat(ts,LSC_DispSequence," ",keynamtab[fno][kno],NULL);
- }
- else {
- switch (fno) {
- ¸SELDETAIL¸
- }
- }
- pad(sout,ts,255,Right);
- return(sout);
- }
-
- void display_the_find(long trecno, long oldnum)
- {
- align_rec(trecno ? trecno : oldnum);
- }
-
- void find_record(void)
- {
- int tpos,i, dsplen;
- bool tb,abort;
- char temp_pic[DB_Klen+1];
- long trecno,oldnum;
- char chosen[21];
- string numstr, choosestr;
- string ts;
- string aPictureField;
- uchar aFieldType;
-
- exitcode = ' ';
- if ((usedrecs(datf[filno]) > 0) && (filinuse[filno])) {
- oldnum = (recavail[filno]) ? recno[filno] : 0;
- if ((keynum > maxkeyno) || (keylen[filno][keynum] == 0)) keynum = 1;
- abort = False;
- dsplen = 0; /* SN 3.5 */
- for (i = 1; i <= maxkeyno; ++i) dsplen += strlen(keynamtab[filno][i]); /* SN 3.5 */
- dsplen = (dsplen > 255) ? 14 : 20; /* SN 3.5 */
- i = keynum;
- choosestr[0] = '\0';
- numstr[0] = '\0';
- do {
- if ((keylen[filno][i] != 0) && (keynamtab[filno][i][0] != '\0')) {
- strconcat(numstr,numstr,istr(ts,(long)i,2),"|",NULL);
- strconcat(choosestr,choosestr,pad(ts,keynamtab[filno][i],dsplen,Right),"|",NULL); /* SN 3.5 */
- }
- i++;
- if (i > maxkeyno) i = 1;
- } while (i != keynum);
- gotoxy((scrwid-20)/2,scrhgt-maxkeyno-4);
- tb = permitesc;
- permitesc = True;
-
- i = strlen(numstr);
- if (!i) exitcode = QitKey;
- else if (i == 3) strcopy(chosen, numstr, 0, 2);
- else choose(key, numstr, choosestr, chosen);
-
- permitesc = tb;
- if (chosen[0] != 0) keynum = (int) ival(chosen);
- abort = (bool)(exitcode == QitKey);
- if (!abort) {
- strconcat(ts," ",LSC_EnterTheKey," : ",trim(ts,keynamtab[filno][keynum])," ",NULL);
- if (openwin(0,2,scrhgt-2,78,1,31,31,8,"ƒø≥Ÿƒ¿≥⁄",TopCnt,ts)) {
- twinp = curwin;
- twinp->disp = True;
- dispwindow(twinp);
- fillstr(key,DB_Klen,' ');
- strchcat(strip(temp_pic,istr(temp_pic,(long)DB_Klen,3)),Pic_X);
- tpos = (78-(strlen(LSC_EnterOrEsc)+DB_Klen+2))/2;
- writewxy(LSC_EnterOrEsc,31,(byte)tpos,1,twinp);
- tpos = tpos + strlen(LSC_EnterOrEsc) + 1;
-
- /* Written by SN 3.5 - Start */
-
- strcpy(aPictureField, keyseg1fld[filno][keynum]->pic);
- aFieldType = keyseg1fld[filno][keynum]->typ;
-
- expand(choosestr, aPictureField);
- switch (aFieldType) {
- case _Ch : {
- fillstr(choosestr, piclen(choosestr, aFieldType), ' ');
- break;
- }
- case _Num : {
- fstr(choosestr, 0.0, _calc_int(choosestr), _calc_frac(choosestr));
- break;
- }
- }
-
- dsp_fld(tpos,1,choosestr, aFieldType, aPictureField, 1, 40, 0, twinp);
- edt_fld(tpos,1,choosestr, aFieldType, aPictureField, 40, 0, twinp);
- *skey = '\0';
- strcopy(key,choosestr,0,keyseg1len[filno][keynum]);
- if (aFieldType == _Num && (valu(key) == 0)) *key = '\0';
- pic_fld(choosestr, choosestr, aFieldType, 0, 0, aPictureField);
-
- /* Written by SN 3.5 - Finish */
-
- closewin(&twinp);
- if (exitcode == Esc) goto Find_Exit;
- if (!empty(key)) {
- trim(key,keyexpr(key,filno,keynum,key));
- strcpy(skey,key);
- }
- searchkey(idxkey[filno][keynum],&recno[filno],key);
- if ((!ok) || (strsearch(key,skey) != key)) {
- audible(Warning);
- strconcat(ts, LSC_NoExactMatch, choosestr, NULL);
- strcopy (ts, ts, 0, 76);
- dspmsge("",ts,4.0);
- }
- tempkey[0] = '\0';
- if (ok) {
- nextkey(idxkey[filno][keynum],&recno[filno],key);
- if (ok) strcpy(tempkey,key);
- prevkey(idxkey[filno][keynum],&recno[filno],key);
- }
- else prevkey(idxkey[filno][keynum],&recno[filno],key);
- if (!skey[0] || (strsearch(key,skey) != key) || (strsearch(tempkey,skey) == tempkey)) {
- trecno = list_n_choose((byte)filno,(byte)keynum,key,idxkey[filno][keynum],findscrpos[filno][keynum]);
- display_the_find(trecno,oldnum);
- }
- else align_rec(recno[filno]);
- }
- }
- }
- else audible(Warning);
- Find_Exit : ;
- exitcode = ' ';
- }
-
- strptr list(strptr sout, int fno, int kno, keystr ks)
- {
- long trecno;
- keystr lastks;
- bool tok;
- ¸IFDEF TABLES¸
- byte stabsiz;
- ¸ENDDEF¸
-
- if (!listAndAdd) listing = True;
- if ((fno != filno) && (keylen[fno][kno] > 0)) {
- tok = ok;
- scrn_active = False;
- strcpy(lastks,ks);
- clearkey(idxkey[fno][kno]);
- nextkey(idxkey[fno][kno],&recno[fno],lastks);
- lastks[0] = '\0';
- trecno = -1;
- if (ok) trecno = list_n_choose((byte)fno,(byte)kno,lastks,idxkey[fno][kno],findscrpos[fno][kno]);
- if (trecno == 0 && listAndAdd) trecno = add2CodeFile(fno);
- if (trecno > 0) {
- ok = True;
- recno[fno] = trecno;
- link = No_Link;
- getarec(fno);
- link = Up_N_Down;
- strcopy(ks,makekey(lastks,fno,kno),0,strlen(ks));
- }
- else clear_rec(fno);
-
- ok = tok;
- scrn_active = True;
- ¸IFDEF TABLES¸
- stabsiz = tabsize[filno];
- tabsize[filno] = 1;
- displayrec(filno,scrno);
- tabsize[filno] = stabsiz;
- ¸ELSEDEF¸
- displayrec(filno,scrno);
- ¸ENDDEF¸
- }
- fldnum--;
- listing = False;
- sout[0] = '\0';
- return(sout);
- }
-
- /* SN 3.5 - The complete Function was created for 3.5 */
-
- strptr listadd(strptr sout, int fno, int kno, keystr aKey)
- {
- listAndAdd = True;
- list(sout, fno, kno, aKey);
- listAndAdd = False;
- return(sout);
- }
-
- ¸IFDEF ADJUST¸
- void afteradjdisp(int fno)
- {
- int i;
-
- for (i = 1; i <= fno; i++) if (afteradj[fno][i] > 0) {
- (uw.wa[winforfile[i]])->disp = False;
- ¸IFDEF TABLES¸
- link = No_Link;
- displayrec(0,winforfile[i]);
- link = Up_N_Down;
- ¸ELSEDEF¸
- displayrec(filno,winforfile[i]);
- ¸ENDDEF¸
- afteradjdisp(i);
- hidewin(T_ON,uw.wa[winforfile[i]]);
- }
- }
-
- void updatekeys(int f)
- {
- int i;
- keystr key;
-
- for (i=1; i <= maxkeyno; i++) {
- getakey(key,f,i);
- ¸IFDEF MUSER¸
- must_secure_index(f,i,Lock);
- deletekey(idxkey[f][i],&recno[f],tkeytab[i]);
- addkey(idxkey[f][i],&recno[f],key);
- must_secure_index(f,1,UnLock);
- ¸ELSEDEF¸
- deletekey(idxkey[f][i],&recno[f],tkeytab[i]);
- addkey(idxkey[f][i],&recno[f],key);
- ¸ENDDEF¸
- if (!ok) dberrm(LSC_BadAdjust);
- }
- }
-
- void adjust(int fno, uchar mode)
- {
- int i;
-
- switch (fno) {
- ¸adjust¸
- }
- }
- ¸ENDDEF¸
-
- ¸IFDEF LINKED¸
- void setlinkage(int fno)
- {
- switch (fno) {
- ¸setlink¸
- }
- }
- ¸ENDDEF¸
-
- void remove_keys(int badkey)
- {
- long recd;
- int keyno;
-
- for (keyno = 1; keyno <= (badkey-1); keyno++)
- if (strcmp(savkey[keyno],tkeytab[keyno]) != 0) {
- recd = recno[filno];
- ¸IFDEF MUSER¸
- must_secure_index(filno,keyno,Lock);
- deletekey(idxkey[filno][keyno],&recd,tkeytab[keyno]);
- must_secure_index(filno,keyno,UnLock);
- ¸ELSEDEF¸
- deletekey(idxkey[filno][keyno],&recd,tkeytab[keyno]);
- ¸ENDDEF¸
- }
- }
-
- ¸IFDEF LINKED¸
- void putlink(int nummer)
- {
- string tkey;
- long trecno;
- int tf;
-
- do {
- strcpy(key,savelnk[nummer]);
- strcpy(tkey,key);
- searchkey(idxkey[nummer][1],&recno[nummer],key);
- ok = (bool)(ok && (strsearch(key,tkey) == key));
- if (ok) {
- ¸IFDEF MUSER¸
- must_secure_rec(nummer,recno[nummer],1);
- ¸ENDDEF¸
- link = No_Link;
- getarec(nummer);
- link = Up_N_Down;
- for (tf = 1; tf <= maxkeyno; tf++)
- getakey(savkey[tf],nummer,tf);
- for (tf = 1; tf <= maxfilno; tf++)
- if (linkback[tf].f == nummer) getlink(savelnk[tf],tf);
- setlinkage(nummer);
- putarec(nummer);
- for (tf = 1; tf <= maxkeyno; tf++) {
- getakey(tkey,nummer,tf);
- if (strcmp(savkey[tf],tkey) != 0) {
- ¸IFDEF MUSER¸
- must_secure_index(nummer,tf,Lock);
- deletekey(idxkey[nummer][tf],&recno[nummer],savkey[tf]);
- addkey(idxkey[nummer][tf],&recno[nummer],tkey);
- must_secure_index(nummer,tf,UnLock);
- ¸ELSEDEF¸
- deletekey(idxkey[nummer][tf],&recno[nummer],savkey[tf]);
- addkey(idxkey[nummer][tf],&recno[nummer],tkey);
- ¸ENDDEF¸
- }
- }
- for (tf = 1; tf <= maxfilno; tf++)
- if ((linkback[tf].f == nummer) && filinuse[tf] &&
- (strcmp(savelnk[tf],getlink(tkey,tf)) != 0)) putlink(tf);
- ¸IFDEF MUSER¸
- tv = lock_datf(datf[nummer],recno[nummer],UnLock);
- ¸ENDDEF¸
- }
- } while (ok);
- ok = True;
- }
- ¸ENDDEF¸
-
- void edit_record(void)
- {
- bool changedkey;
- int fno,tf,keyno;
- long trecno;
- keystr tk;
-
- ¸IFDEF MEMOS¸
- editmode = True;
- ¸ENDDEF¸
-
- lastrecop = _Edit;
-
- ¸IFDEF MUSER¸
- ok = True;
- tf = filno;
- trecno = recno[filno];
- ¸IFDEF LINKED¸
- if (linkback[filno].f > 0) traceback(filno); else {
- getakey(key,filno,1);
- findmulti(filno,&recno[filno],key);
- }
- ¸ELSEDEF¸
- getakey(key,filno,1);
- findmulti(filno,&recno[filno],key);
- ¸ENDDEF¸
- displayrec(filno,scrno);
- if ((filno != tf) || (recno[filno] != trecno) || !ok) {
- dspmsge(LSC_Warning,LSC_SomeoneDeleted,4.0);
- return;
- }
- if (lock_datf(datf[filno],recno[filno],Lock) != 0) {
- audible(Error);
- dspmsge(LSC_Warning,LSC_EditRecInUse,4.0);
- }
- else if (status_ok(filno)) {
- ¸ELSEDEF¸
- if (status_ok(filno)) {
- ¸ENDDEF¸
- getarec(filno);
- displayrec(filno,scrno);
- for (keyno = 1; keyno <= maxkeyno; keyno++)
- getakey(savkey[keyno],filno,keyno);
- ¸IFDEF LINKED¸
- for (fno = 1; fno <= maxfilno; fno++) if (linkback[fno].f == filno)
- getlink(savelnk[fno],fno);
- ¸ENDDEF¸
- ¸IFDEF ADJUST¸
- adjust(filno,'D');
- ¸ENDDEF¸
- edit_rec(0);
- changedkey = False;
- ¸IFDEF ADJUST¸
- ¸IFDEF LINKED¸
- ¸IFDEF MUSER¸
- for (fno = 1; fno <= maxfilno; fno++)
- if ((linkback[fno].f == filno) && filinuse[fno] && multiuser &&
- (strcmp(savelnk[fno],getlink(tk,fno)) != 0)) {
- dberrm(LSC_PreserveLink);
- exitcode = QitKey;
- }
- ¸ENDDEF¸
- ¸ENDDEF¸
- ¸ENDDEF¸
- if (exitcode != QitKey) {
- keyno = 1;
- while ((keyno <= maxkeyno) && (exitcode != QitKey)) {
- getakey(tkeytab[keyno],filno,keyno);
- if (strcmp(tkeytab[keyno],savkey[keyno]) == 0)
- ok = True;
- else {
- ¸IFDEF MUSER¸
- must_secure_index(filno,keyno,Lock);
- addkey(idxkey[filno][keyno],&recno[filno],tkeytab[keyno]);
- must_secure_index(filno,keyno,UnLock);
- ¸ELSEDEF¸
- addkey(idxkey[filno][keyno],&recno[filno],tkeytab[keyno]);
- ¸ENDDEF¸
- if (!ok) {
- remove_keys(keyno);
- audible(Error);
- dspmsge(LSC_BaseError,LSC_KeyExists,4.0);
- edit_rec(keyfld[filno][keyno]);
- keyno = 0;
- }
- }
- keyno++;
- }
- if (exitcode != QitKey) {
- for (keyno = 1; keyno <= maxkeyno; keyno++)
- if (strcmp(tkeytab[keyno],savkey[keyno]) != 0) {
- changedkey = True;
- strcpy(tk,tkeytab[keyno]);
- strcpy(tkeytab[keyno],savkey[keyno]);
- strcpy(savkey[keyno],tk);
- }
- remove_keys(maxkeyno+1);
- putarec(filno);
- ¸IFDEF LINKED¸
- for (fno = 1; fno <= maxfilno; fno++)
- if ((linkback[fno].f == filno) &&
- (linkback[fno].t == _Unique) &&
- filinuse[fno] &&
- (strcmp(savelnk[fno],getlink(tk,fno)) != 0)) putlink(fno);
- ¸ENDDEF¸
- }
- else ok = True;
- }
- getarec(filno);
- ¸IFDEF ADJUST¸
- adjust(filno,'A');
- afteradjdisp(filno);
- ¸ENDDEF¸
- ¸IFDEF TABLES¸
- if ((tabsize[filno] > 1) && changedkey) {
- getakey(savkey[1],filno,1);
- findmulti(filno,&recno[filno],savkey[1]);
- align_tab(filno);
- }
- ¸ENDDEF¸
- displayrec(filno,scrno);
- ¸IFDEF MUSER¸
- tv = lock_datf(datf[filno],recno[filno],UnLock);
- ¸ENDDEF¸
-
- lastrecop = Nul;
-
- ¸IFDEF MEMOS¸
- editmode = False;
- ¸ENDDEF¸
- }
- }
-
- ¸IFDEF MEMOS¸
- void deletememos(void *fb, void *buf, int fno)
- {
- word w;
- long mrec,trec;
- genbuf sbuf;
- fldblk *fblk;
- fldtyp *fld;
- byteptr buffer;
-
- fblk = (fldblk *) fb;
- buffer = (byteptr) buf;
- memmove(&sbuf[1],buf,fblk->dsz);
- w = 0;
- do {
- fld = &(*fblk->farr)[w];
- if (fld->typ == _Memo) {
- memmove(&mrec,fld->faddr,4);
- while (mrec != 0) {
- getrec(datf[fno],mrec,buf);
- memmove(&trec,&buffer[(fblk->dsz-3)-1],4);
- deleterec(datf[fno],mrec);
- mrec = trec;
- }
- memmove(buf,&sbuf[1],fblk->dsz);
- }
- w++;
- } while (w < fblk->numf);
- }
- ¸ENDDEF¸
-
- ¸IFDEF MUSER¸
- ¸IFDEF LINKED¸
- bool lock_linked(int fno, int lck)
- {
- bool savok, tb;
- int i, keyno;
- uchar ans[2];
- uchar tpic[2];
- keystr tkey, tkey2;
-
- strcpy(ans, " ");
- strcpy(tpic, " ");
- tb = True;
- ans[0] = _Retry;
- tpic[0] = Pic_U;
- if (fno != filno) { /* "filno" Already Locked By Delete_Record */
- do {
- tv = lock_datf(datf[fno],recno[fno],lck);
- if (tv == -1)
- dbgetstr(ans,_Ch,LSC_LinkedDelRecInUse,ans,tpic,"",chkabortretry,nohelp);
- } while ((tv != 0) && (ans[0] != _Abort));
- }
- tb = (ans[0] == _Retry);
- if (tb) {
- link = No_Link;
- getarec(fno);
- link = Up_N_Down;
- for (i = 1; i <= maxfilno; i++) {
- if ((linkback[i].t == _Unique) && (linkback[i].f == fno)) {
- if (filinuse[i]) {
- getlink(tkey,i); strcpy(tkey2,tkey);
- searchkey(idxkey[i][1],&recno[i],tkey2);
- savok = (bool)(ok && (strsearch(tkey2,tkey) == tkey2));
- while (savok && tb) {
- tb = lock_linked(i,lck);
- nextkey(idxkey[i][1],&recno[i],tkey2);
- savok = (bool)(ok && (strsearch(tkey2,tkey) == tkey2));
- }
- ok = True; /* Restore OK to True */
- }
- }
- }
- }
- return(tb);
- }
- ¸ENDDEF¸
- ¸ENDDEF¸
-
- void delarec(int fno)
- {
- string tkey,tkey2;
- bool savok;
- int i,keyno;
- long delrecno;
-
- ¸IFDEF MUSER¸
- lockByDel[fno] = True;
- ¸ENDDEF¸
- ¸IFDEF LINKED¸
- ¸IFDEF MUSER¸
- if (fno == filno) {
- savok = lock_linked(fno,Lock);
- if (!savok) {
- savok = lock_linked(fno,UnLock); nextrec = recno[fno]; return;
- }
- }
- ¸ENDDEF¸
- getarec(fno);
- for (i = 1; i <= maxfilno; i++) {
- if ((linkback[i].t == _Unique) && (linkback[i].f == (byte)fno)) {
- if (filinuse[i]) {
- getlink(tkey,i);
- strcpy(tkey2,tkey);
- do {
- searchkey(idxkey[i][1],&recno[i],tkey2);
- savok = (bool)(ok && (strsearch(tkey2,tkey) == tkey2));
- if (savok) delarec(i);
- } while (savok);
- }
- }
- }
- ¸ELSEDEF¸
- getarec(fno);
- ¸ENDDEF¸
- delrecno = recno[fno];
- ¸IFDEF MUSER¸
- if (fno != filno) must_secure_rec(fno,0L,2);
- ¸ENDDEF¸
- ¸IFDEF MEMOS¸
- switch (fno) {
- ¸DELMEMOS¸
- }
- ¸ENDDEF¸
- deleterec(datf[fno], delrecno);
- for (keyno = 1; keyno <= maxkeyno; keyno++) {
- if (keylen[fno][keyno] > 0) {
- delrecno = recno[fno];
- getakey(tkey,fno,keyno);
- ¸IFDEF MUSER¸
- must_secure_index(fno,keyno,Lock);
- deletekey(idxkey[fno][keyno],&delrecno,tkey);
- must_secure_index(fno,keyno,UnLock);
- ¸ELSEDEF¸
- deletekey(idxkey[fno][keyno],&delrecno,tkey);
- ¸ENDDEF¸
- }
- }
- ¸IFDEF ADJUST¸
- adjust(fno,'D');
- ¸ENDDEF¸
- ¸IFDEF MUSER¸
- if (fno != filno) {
- tv = lock_datf(datf[fno],recno[fno],UnLock);
- tv = lock_datf(datf[fno],0L,UnLock);
- }
- ¸ENDDEF¸
- ¸IFDEF MUSER¸
- lockByDel[fno] = False;
- ¸ENDDEF¸
- }
-
- void delete_record(void)
- {
- byte i,ch;
- long trecno;
- keystr nxtkey;
- bool tok,child;
- int tf;
- string msg;
-
- lastrecop = _Delete;
- ¸IFDEF MUSER¸
- ok = True;
- tf = filno;
- trecno = recno[filno];
- ¸IFDEF LINKED¸
- if (linkback[filno].f > 0) traceback(filno); else {
- getakey(key,filno,1);
- findmulti(filno,&recno[filno],key);
- }
- ¸ELSEDEF¸
- getakey(key,filno,1);
- findmulti(filno,&recno[filno],key);
- ¸ENDDEF¸
- displayrec(filno,scrno);
- if ((filno != tf) || (recno[filno] != trecno) || !ok) {
- dspmsge(LSC_Warning,LSC_SomeoneDeleted,4.0);
- return;
- }
- if (lock_datf(datf[filno],0L,Lock) != 0) {
- audible(Error);
- dspmsge(LSC_Warning,LSC_StatusUnavail,4.0);
- }
- else if (lock_datf(datf[filno],recno[filno],Lock) != 0) {
- audible(Error);
- dspmsge(LSC_Warning,LSC_DelRecInUse,4.0);
- tv = lock_datf(datf[filno],0L,UnLock);
- }
- else if (status_ok(filno)) {
- ¸ELSEDEF¸
- if (status_ok(filno)) {
- ¸ENDDEF¸
- getarec(filno);
- displayrec(filno,scrno);
- ¸IFDEF LINKED¸
- child = False;
- for (i = 1; i <= maxfilno; i++)
- child = (bool)(child || ((linkback[i].f == (byte)filno) && (filinuse[i])));
- strcpy(msg,(child) ? LSC_DelLinkedRec : LSC_ConfirmDelRec);
- ¸ELSEDEF¸
- strcpy(msg, LSC_ConfirmDelRec);
- ¸ENDDEF¸
- do {
- dspmsge(LSC_Warning,msg,0.0);
- ch = upperch(getkey());
- } while ((ch !=_YES) && (ch != QitKey));
- if (ch == _YES) {
- trecno = recno[filno];
- prevkey(idxkey[filno][1],&recno[filno],key);
- if (ok) {
- strcpy(nxtkey,key);
- nextrec = recno[filno];
- }
- tok = ok;
- nextkey(idxkey[filno][1],&recno[filno],key);
- if (recno[filno] != trecno) {
- audible(Error);
- dspmsge(LSC_BaseError,LSC_CorruptIndex,4.0);
- getarec(filno);
- displayrec(filno,scrno);
- }
- else {
- ok = True;
- message(NULL, LSC_Deleting);
- delarec(filno);
- message(NULL, "");
- ¸IFDEF ADJUST¸
- afteradjdisp(filno);
- ¸ENDDEF¸
- if (tok) {
- recno[filno] = nextrec;
- findmulti(filno,&recno[filno],nxtkey);
- if (ok) {
- getarec(filno);
- ¸IFDEF TABLES¸
- if (tabsize[filno] != 1) align_tab(filno);
- ¸ENDDEF¸
- if (status_ok(filno)) displayrec(filno,scrno); else top_record();
- }
- else top_record();
- }
- else top_record();
- }
- }
- ¸IFDEF MUSER¸
- tv = lock_datf(datf[filno],trecno,UnLock);
- tv = lock_datf(datf[filno],0L,UnLock);
- ¸ENDDEF¸
- }
- else audible(Warning);
- }
-
- strptr autoinc(keystr sout, int kno)
- {
- float tl = 1; /* SN 3.5 */
- char tempString1[10], /* SN 3.5 */
- tempString2[10], /* SN 3.5 */
- tempString3[10], /* SN 3.5 */
- tempString4[10], /* SN 3.5 */
- tempString5[10], /* SN 3.5 */
- fileName[20]; /* SN 3.5 */
-
- clearkey(idxkey[filno][kno]);
- prevkey(idxkey[filno][kno],&recno[filno],key);
-
- if (!ok) strcpy(sout,"1");
- else strip(sout,fstr(sout,valu(key)+1,11,0));
-
- ¸IFDEF MUSER¸
- if (multiuser) { /* SN 3.5 */
- *fileName = *tempString1 = *tempString2 = Nul;
- *tempString3 = *tempString4 = *tempString5 = Nul;
- istr(tempString4, filno, 2);
- istr(tempString5, kno, 2);
- strip(tempString2, tempString4);
- strip(tempString3, tempString5);
- strcopy(tempString1, "¸MODNAME¸", 0, 5);
- strconcat(fileName, "~", tempString1, tempString2, tempString3, NULL);
- tl = txtinc(fileName, tl);
- fstr(sout, tl, 11, 0);
- }
- ¸ENDDEF¸
- return (strip(tempString1, sout));
- }
-
- void addarec(void)
- {
- switch (filno) {
- ¸ADDREC¸
- }
- }
-
- void add_record(char func)
- {
- ¸IFDEF TABLES¸
- byte stabsiz,stabidx;
- ¸ENDDEF¸
- int fno;
- long savr,recd;
- int tf,keyno;
- bool rav;
- string tts;
-
- lastrecop = func;
- rav = True;
- ¸IFDEF LINKED¸
- ¸IFDEF MUSER¸
- if (linkback[filno].f > 0) {
- tf = filno;
- traceback(filno);
- displayrec(filno,scrno);
- if (filno != tf) {
- dspmsge(LSC_Warning,LSC_SomeoneDeleted,4.0);
- return;
- }
- }
- ¸ENDDEF¸
- if (linkback[filno].f > 0) rav = recavail[linkback[filno].f];
- ¸ENDDEF¸
- if ((usedrecs(datf[filno]) >= maxrec[filno]) || !rav) {
- if (rav) dspmsge("",LSC_MaxRecsReached,4.0);
- else dspmsge("",LSC_NoParentRec,4.0);
- }
- else {
- if (ok) savr = recno[filno]; else savr = 0;
- scrn_active = False;
- cleartop = (bool)(func == 'A');
- clear_rec(filno);
- scrn_active = True;
- ¸IFDEF MEMOS¸
- if (!cleartop)
- switch (filno) {
- ¸CLEARMEMO¸
- }
- ¸ENDDEF¸
- cleartop = True;
- ¸SETFIELD¸
- ¸IFDEF TABLES¸
- stabsiz = 1;
- if (tabsize[filno] > 1) {
- stabidx = tabidx[filno];
- if (tabidx[filno] == tabsize[filno])
- tabidx[filno] = 1;
- else
- tabidx[filno] = tabused[filno]+1;
- stabsiz = tabsize[filno];
- tabsize[filno] = 1;
- }
- leaveclear = True;
- ¸ENDDEF¸
- displayrec(filno,scrno);
- edit_rec(0);
- if (exitcode != QitKey) {
- ¸IFDEF MUSER¸
- must_secure_rec(filno,0L,2);
- addarec();
- tv = lock_datf(datf[filno],recno[filno],Lock);
- tv = lock_datf(datf[filno],0L,UnLock);
- ¸ELSEDEF¸
- addarec();
- ¸ENDDEF¸
- for (keyno = 1; keyno <= maxkeyno; keyno++) savkey[keyno][0] = '\0';
- keyno = 1;
- ok = True;
- while ((keyno <= maxkeyno) && (exitcode != QitKey)) {
- if (keylen[filno][keyno] > 0) {
- getakey(tkeytab[keyno],filno,keyno);
- ¸IFDEF MUSER¸
- must_secure_index(filno,keyno,Lock);
- addkey(idxkey[filno][keyno],&recno[filno],tkeytab[keyno]);
- must_secure_index(filno,keyno,UnLock);
- ¸ELSEDEF¸
- addkey(idxkey[filno][keyno],&recno[filno],tkeytab[keyno]);
- ¸ENDDEF¸
- if (!ok) {
- remove_keys(keyno);
- audible(Error);
- dspmsge(LSC_BaseError,LSC_KeyExists,4.0);
- edit_rec(keyfld[filno][keyno]);
- if (exitcode == QitKey) {
- recd = recno[filno];
- ¸IFDEF MUSER¸
- must_secure_rec(filno,0L,2);
- deleterec(datf[filno],recd);
- tv = lock_datf(datf[filno],0L,UnLock);
- ¸ELSEDEF¸
- deleterec(datf[filno],recd);
- ¸ENDDEF¸
- recno[filno] = savr;
- }
- else {
- keyno = 0;
- putarec(filno);
- }
- }
- }
- keyno++;
- }
- ¸IFDEF ADJUST¸
- if (exitcode != QitKey) {
- adjust(filno,'A');
- afteradjdisp(filno);
- }
- ¸ENDDEF¸
- ¸IFDEF MUSER¸
- tv = lock_datf(datf[filno],recno[filno],UnLock);
- ¸ENDDEF¸
- }
- else recno[filno] = savr;
- if (exitcode == QitKey) {
- ¸IFDEF TABLES¸
- if (stabsiz > 1) tabidx[filno] = stabidx;
- ¸ENDDEF¸
- ¸IFDEF MEMOS¸
- ¸IFDEF MUSER¸
- must_secure_rec(filno,0L,2);
- ¸ENDDEF¸
- fno = filno;
- switch (fno) {
- ¸DELMEMOS¸
- }
- ¸IFDEF MUSER¸
- tv = lock_datf(datf[filno],0L,UnLock);
- ¸ENDDEF¸
- ¸ENDDEF¸
- }
- ¸IFDEF TABLES¸
- if (stabsiz > 1) tabsize[filno] = stabsiz;
- leaveclear = False;
- ¸ENDDEF¸
- ok = (bool)(ok || (savr > 0));
- getarec(filno);
- ¸IFDEF TABLES¸
- if ((exitcode != QitKey) && (tabsize[filno] > 1)) {
- getakey(skey,filno,1);
- findmulti(filno,&recno[filno],skey);
- align_tab(filno);
- }
- ¸ENDDEF¸
- displayrec(filno,scrno);
- }
- lastrecop = Nul;
- }
-
- void initialize(void)
- {
- ¸KEYFIELD¸
- command = Cmd_No_Command;
- deltas = def1.deltat;
- keynum = 1;
- scrno = 1;
- _trace = 0;
- menuanchor = 0;
- link = Up_N_Down;
- listing = False;
- listAndAdd = False;
- ¸IFDEF TABLES¸
- leaveclear = False;
- switchtab = False;
- ¸ENDDEF¸
- scrn_active = False;
- cleartop = True;
- for (filno = 1; filno <= maxfilno; filno++) {
- recno[filno] = 0;
- ¸IFDEF MUSER¸
- lockByDel[filno] = False;
- ¸ENDDEF¸
- ¸IFDEF TABLES¸
- tabrecno[filno] = 0;
- ¸ENDDEF¸
- ¸IFDEF LINKED¸
- clear_rec(filno);
- ¸ELSEDEF¸
- top_record();
- ¸ENDDEF¸
- recavail[filno] = (bool)(usedrecs(datf[filno]) > 0);
- ¸IFDEF TABLES¸
- tabidx[filno] = 1; tabused[filno] = 0;
- ¸ENDDEF¸
- }
- ¸IFDEF LINKED¸
- for (filno = 1; filno <= maxfilno; filno++) if (linkback[filno].f == 0) top_record();
- ¸ENDDEF¸
- scrn_active = True;
- filno = 1;
- }
-
- bool custom_key(int scr, int fno, int *fld, uchar *key)
- {
- bool tb;
-
- ¸codedisp¸
- return(False);
- }
-
- void on_error(void)
- {
- closefiles();
- }
-
- void swapmenu(void)
- {
- bool savdisp;
- byte ni,tl,tw,tlen;
- itmptr titm;
- mnuptr m;
-
- savdisp = (bool)((dm.curmnu->winp != NULL) && dm.curmnu->winp->disp);
- if (savdisp) zapmnu(&dm,dm.curmnu);
- m = dm.curmnu;
- m->mtyp = (byte)((m->mtyp == Vert) ? 2 : Vert);
- tw = 1; ni = 0; tl = 0;
- titm = m->fitm;
- do {
- ni++; tl += m->mtyp;
- if (m->mtyp == Vert) { titm->ix = 2; titm->iy = ni; }
- else { titm->ix = tl; titm->iy = 1; }
- tlen = (byte)strlen(titm->prompt); tl += tlen;
- if (tlen > tw) tw = tlen;
- titm = titm->nitm;
- } while (titm != m->fitm);
- if (m->mtyp == Vert) { m->widm = tw+2; m->hgtm = ni; }
- else { m->widm = tl+m->mtyp-2; m->hgtm = 1; }
- if (m->mtyp != Vert) {
- m->ym = (m->xm == 2) ? 1 : scrhgt;
- m->xm = 1; m->mbchrs[0] = '\0';
- }
- else {
- if (m->ym == 1) { m->ym = 2; m->xm = scrwid-m->widm; }
- else { m->ym = scrhgt-m->hgtm; m->xm = 2; }
- m->mbchrs[0] = 'ƒ';
- }
- if (savdisp) dspmnu(&dm,dm.curmnu);
- menuanchor = (menuanchor+1) % 4;
- }
-
- void changeto(pathstr newpath, int *res)
- {
- *res = (changedir(newpath)) ? 0 : 1;
- if (*res == 0) {
- getcurrentdir(datapath,0);
- pathSwap = True;
- }
- }
-
- void newload(mnufrec *m, pathstr newmenu)
- {
- int i;
- pathstr newnam;
-
- strcpy(newnam,newmenu);
- svm = smc;
- smc = db_malloc(sizeof(savmtyp));
- smc->savprv = svm;
- strcpy(smc->savnam,m->mnufnam);
- smc->savno = m->curmnu->mno;
- strcpy(smc->savprompt,m->curitm->prompt);
- if (dm.curitm->selpath[0] != '\0') {
- getcurrentdir(smc->savpath,0);
- changeto(dm.curitm->selpath,&i);
- }
- else {
- i = 0;
- smc->savpath[0] = '\0';
- }
- if (i == 0) {
- disposemnus(&dm);
- strcpy(dm.mnufnam,newnam);
- initmnu(&dm,0,0,OnDisk);
- dispallwin();
- if (dm.curmnu == NULL) {
- if (smc->savpath[0] != '\0')
- changeto(smc->savpath,&i);
- strcpy(dm.mnufnam,smc->savnam);
- initmnu(&dm,0,0,OnDisk);
- dispallwin();
- jumptomnu(&dm,smc->savno);
- do
- dm.curitm = dm.curitm->nitm;
- while ((strcmp(smc->savnam,dm.curitm->prompt) != 0) &&
- (dm.curitm != dm.curmnu->fitm));
- db_free(smc);
- smc = svm;
- }
- else {
- dspmnu(&dm,dm.curmnu);
- }
- }
- else {
- db_free(smc);
- smc = svm;
- doserr(3,dm.curitm->selpath);
- }
- pathSwap = True;
- }
-
- void setcommand(byte c_num)
- {
- switch(c_num) {
- case 1 : command = Cmd_Next_Record; break;
- case 2 : command = Cmd_Prev_Record; break;
- case 3 : command = Cmd_Find_Record; break;
- case 4 : command = Cmd_Top_Record; break;
- case 5 : command = Cmd_Last_Record; break;
- case 6 : command = Cmd_Edit_Record; break;
- case 7 : command = Cmd_Add_Record; break;
- case 8 : command = Cmd_Copy_Record; break;
- case 9 : command = Cmd_Delete_Record; break;
- case 10 : command = Cmd_Next_File; break;
- case 11 : command = Cmd_Prev_File; break;
- case 12 : command = Cmd_Swap_Menu; break;
- }
- }
-
- void do_proc(int procno, mnufrec *m)
- {
- setcommand(procno);
- hidewin(T_OFF,dm.curmnu->winp);
- switch (procno) {
- case 1 : next_record(_Next); break;
- case 2 : next_record(_Prev); break;
- case 3 : find_record(); break;
- case 4 : if (status_ok(filno)) top_record(); else audible(Warning); break;
- case 5 : last_record(); break;
- case 6 : if (status_ok(filno)) {
- edit_record();
- getakey(key,filno,1);
- findmulti(filno,&recno[filno],key);
- if (!ok) top_record();
- }
- else audible(Warning); break;
- case 7 :
- add_record('A');
- getakey(key,filno,1);
- findmulti(filno,&recno[filno],key);
- if (!ok) top_record();
- break;
- case 8 : if (status_ok(filno)) {
- add_record('C');
- getakey(key,filno,1);
- findmulti(filno,&recno[filno],key);
- if (!ok) top_record();
- }
- else audible(Warning); break;
- case 9 : delete_record(); break;
- case 10: switch_file('+'); break;
- case 11: switch_file('-'); break;
- case 12: setdeltas(); break;
- case 13: swapmenu(); break;
- /***************************************************************************
- * [DG] 09/11/92 -- Added cases 101-116, which will switch instantly to *
- * files 1-16, by subtracting 100 from the case number. *
- * If the file number is larger than the maximum defined *
- * file, we switch to the highest valid file. *
- ***************************************************************************/
- case 101:
- case 102:
- case 103:
- case 104:
- case 105:
- case 106:
- case 107:
- case 108:
- case 109:
- case 110:
- case 111:
- case 112:
- case 113:
- case 114:
- case 115:
- case 116: filno = (procno - 100);
- if (filno > maxfilno) filno = maxfilno;
- switch_file(' ');
- break;
- /***********************/ /* [DG] End Modification */ /*******************/
- }
- hidewin(T_ON,dm.curmnu->winp);
- dispwindow(dm.curmnu->winp);
- }
-
- void do_ctl(mnufrec *m, itmptr itm)
- {
- string ts;
- uchar yes[2],tpic[2];
-
- if ((m->curmnu != NULL) && (itm != NULL)) {
- switch (itm->seltyp) {
- case _Proc : do_proc((int) ival(itm->selact),m); break;
- case _Menu :
- if ((ival(itm->selact) > 0) && (m->mat[(int) ival(itm->selact)-1] != NULL)) {
- if (m->mat[(int) ival(itm->selact)-1]->winp != NULL)
- jumptomnu(m,(byte) ival(itm->selact));
- else {
- m->mat[(int) ival(itm->selact)-1]->pmnu = m->curmnu->mno;
- m->curmnu = m->mat[(int) ival(itm->selact)-1];
- dspmnu(m,m->curmnu);
- m->curitm = m->curmnu->litm;
- m->level = 0;
- }
- }
- break;
- case _Quit :
- dbgetstr(ts,_Ch,LSC_QuitDataBase,chstr(yes,_YES),chstr(tpic,Pic_U),"",chkyesno,nohelp);
- quit = (bool)((ts[0] == _YES) && (exitcode != QitKey));
- break;
- }
- }
- }
-
- bool initdbm(void)
- {
- strcpy(dm.mnufnam,localmenu);
- initmnu(&dm,0,0,OnDisk);
- return (bool)(dm.curmnu != NULL);
- }
-
- void datenpath(void)
- {
- string ts;
-
- if (uw.bgw != NULL) {
- if (mdate.x != 0)
- if (mdate.m == 0)
- writewxy(datum(ts,sysdate(ts)),0,mdate.x,mdate.y,uw.bgw);
- else
- writewxy(slash(ts,sysdate(ts)),0,mdate.x,mdate.y,uw.bgw);
- if (mpath.x != 0) {
- strcpy(ts,datapath);
- if (strlen(ts) == 3) strcat(ts,applname);
- else { strcat(ts,"\\"); strcat(ts,applname); }
- writewxy(ts,0,mpath.x,mpath.y,uw.bgw);
- }
- }
- }
-
- void do_menu(void)
- {
- byte b;
- uchar ctlkey;
- int err;
- string ts;
- uchar yes[2],tpic[2];
-
- set_addmember(ExitSet,AltX);
- if (initdbm()) {
- for (b = 0; b < def1.anchor; b++) swapmenu();
- strcat(strcpy(uw.wfnam,applname),".DBW");
- err = initwin(&uw);
- if (err == 0) {
- if ((dm.curmnu->ym == 25) && (scrhgt > 25)) dm.curmnu->ym = scrhgt;
- datenpath();
- if (uw.bgw != NULL) uw.bgw->disp = True;
- strcat(strcpy(hw.wfnam,applname),".DBH");
- initwin(&hw);
- dispallwin();
- hidewin(T_ON,uw.wa[1]);
- top_record();
- quit = False;
- dspmnu(&dm,dm.curmnu);
- do {
- if (dm.curitm->sec > gvar->sec) {
- if (dm.curmnu->mtyp == Vert) goud(&dm,Down);
- else gorl(&dm,Right);
- }
- hbar(&dm);
- tandk(0,0,uw.wa[scrno]);
- ctlkey = upperch(getkey());
- if ((dm.curitm->sec > gvar->sec) &&
- ((ctlkey != AltX) && (ctlkey != AltL) && (ctlkey != QitKey)))
- dberrm(LSC_MustLogOn);
- // [DG] 09/09/1992
- // Restructured switch statement to allow (mostly) CUA-compliant hot-keys
- switch (ctlkey) {
- case Enter : if (gvar->sec >= dm.curitm->sec)
- do_ctl(&dm,dm.curitm); break;
- case HlpKey : itemhelp(&dm); break;
- /* Next */ case CtrlRArr : do_proc( 1,&dm); break;
- /* Prev */ case CtrlLArr : do_proc( 2,&dm); break;
- /* Find */ case AltS : do_proc( 3,&dm); break;
- /* Top */ case Home : do_proc( 4,&dm); break;
- /* Last */ case EndKey : do_proc( 5,&dm); break;
- /* Edit */ case CtrlEnter: do_proc( 6,&dm); break;
- /* Add */ case Ins : do_proc( 7,&dm); break;
- /* Copy */ case CtrlC : do_proc( 8,&dm); break;
- /* Del */ case Del : do_proc( 9,&dm); break;
- /* +Fil */ case PgDn : do_proc(10,&dm); break;
- /* -Fil */ case PgUp : do_proc(11,&dm); break;
- /* ScSv */ case AltV : do_proc(12,&dm); break;
- case UArr : if (dm.curmnu->mtyp != Vert) do_proc(2,&dm);
- else goud(&dm,Up); break;
- case DArr : if (dm.curmnu->mtyp != Vert) do_proc(1,&dm);
- else goud(&dm,Down); break;
- case LArr : gorl(&dm,Left); break;
- case RArr : gorl(&dm,Right); break;
- ¸IFDEF TABLES¸
- case CtrlPgUp : if (tabsize[filno] > 1)
- next_tab_page(_Prev); break;
- case CtrlPgDn : if (tabsize[filno] > 1)
- next_tab_page(_Next); break;
- ¸ENDDEF¸
- case AltX : dbgetstr(ts,_Ch,LSC_QuitDataBase,
- chstr(yes,_YES),chstr(tpic,Pic_U),"",
- chkyesno,nohelp);
- quit = (bool)((ts[0] == _YES) &&
- (exitcode != QitKey));
- break;
- case QitKey : if ((dm.curmnu != NULL) &&
- (dm.curmnu->pmnu != 0))
- {
- zapmnu(&dm,dm.curmnu);
- dm.curmnu->litm = dm.curitm;
- dm.curmnu = dm.mat[dm.curmnu->pmnu-1];
- dm.curitm = dm.curmnu->litm;
- dm.level = 0;
- if (dm.curmnu->winp == NULL)
- dspmnu(&dm,dm.curmnu);
- }
- else
- {
- if (filno > 1)
- switch_file('-');
- else
- {
- dbgetstr(ts,_Ch,LSC_QuitDataBase,
- chstr(yes,_YES),
- chstr(tpic,Pic_U),"",
- chkyesno,nohelp);
- quit = (bool)((ts[0] == _YES) &&
- (exitcode != QitKey));
- }
- }
- break;
- default : if (selitm(ctlkey,&dm))
- {
- hbar(&dm);
- do_ctl(&dm,dm.curitm);
- }
- break;
- // End of changes
- }
- } while (!quit);
- }
-
-
- else dberrm(strconcat(ts,DOSErr8," [",uw.wfnam,"]",NULL));
- if ((menuanchor != def1.anchor) || (deltas != def1.deltat)) {
- def1.anchor = menuanchor;
- def1.deltat = deltas;
- updexe(def1.exeid,sizeof(def1));
- }
- disposemnus(&dm);
- closeallwin();
- }
- else dberrm(strconcat(ts,_NoFiles," [",localmenu,"]",NULL));
- }
-
- void main(void)
- {
- extfhc_init();
- db_curs_init();
- db_date_init();
- db_funcs_init();
- db_heap_init();
- db_gvar_init();
- db_key_init();
- db_pswd_init();
- db_win_init();
- db_util_init();
- db_work_init();
- db_tree_init();
- db_list_init();
- ¸IFDEF MANUAL¸
- db_man_init();
- ¸ENDDEF¸
- ¸IFDEF MEMOS¸
- db_mnu_init();
- db_memo_init();
- ¸ELSEDEF¸
- db_mnu_init();
- ¸ENDDEF¸
- ¸IFDEF MUSER¸
- multiuser = True;
- ¸ELSEDEF¸
- multiuser = False;
- ¸ENDDEF¸
- initedit();
- initindex();
- _keyexpr = keyexpr;
- _getarec = getarec;
- _horizrec = horizrec;
- clrscr();
- if (menudriven && !dbcaller) {
- audible(Error);
- dspmsge(LSC_BaseError,LSC_MenuDriven,4.0);
- }
- else if (!validpath()) {
- audible(Error);
- dspmsge(LSC_BaseError,LSC_AbortBadPath,4.0);
- }
- else {
- if (openwin(0,(byte)(80-strlen(LSC_Initializing))/2,12,
- (byte)strlen(LSC_Initializing),1,31,31,8,"ƒø≥Ÿƒ¿≥⁄",TopCnt,"")) {
- twinp = curwin;
- writewxy(LSC_Initializing,31,1,1,twinp);
- hidewin(T_ON,twinp);
- openfiles();
- closewin(&twinp);
- }
- if (fok) {
- shutdown = on_error;
- initialize();
- ¸IFDEF MANUAL¸
- initmanual("¸MANUAL¸");
- ¸ENDDEF¸
- do_menu();
- if (openwin(0,(80-strlen(LSC_ClosingFile))/2,12,
- (byte)strlen(LSC_ClosingFile),1,31,31,8,"ƒø≥Ÿƒ¿≥⁄",TopCnt,"")) {
- twinp = curwin;
- writewxy(LSC_ClosingFile,31,1,1,twinp);
- hidewin(T_ON,twinp);
- closefiles();
- closewin(&twinp);
- }
- }
- else {
- audible(Error);
- dspmsge(LSC_ErrNeededFiles,LSC_ErrMissingFile,5.0);
- }
- }
- clrscr();
- }
-